package com.weakteam.mobile.minimum.common.util;

import android.content.Context;
import android.location.Location;
import android.os.Bundle;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient;
import com.google.android.gms.location.LocationClient;

/**
 * Created by Nail Sharipov (nailxsharipov@gmail.com) on 11.11.2014.
 */
public class CurrentLocationManager implements GooglePlayServicesClient.ConnectionCallbacks,
        GooglePlayServicesClient.OnConnectionFailedListener{

    private static CurrentLocationManager instance;
    private Context context;

    public static CurrentLocationManager getInstance() {
        if (instance == null) {
            instance = new CurrentLocationManager();
        }
        return instance;
    }

    private LocationClient locationClient;

    private Location position;

    public Location getPosition() {
        return position;
    }

    public CurrentLocationManager init(final Context context) {
        this.context = context;
        this.locationClient = new LocationClient(context, this, this);
        return this;
    }

    @Override
    public void onConnected(Bundle dataBundle) {
        SimpleLog.info("Connected");
    }

    @Override
    public void onDisconnected() {
        SimpleLog.info("Disconnected. Please re-connect.");
    }
    @Override
    public void onConnectionFailed(ConnectionResult connectionResult) {
        SimpleLog.info("onConnectionFailed");
    }

}
